import React from 'react'

class DriveLicenseApp extends React.Component {

    componentDidMount() {
        console.log('DriveLicenseApp#componentDidMount/' + JSON.stringify(this.props.card));
        if (!this.props.card.uid)
            this.props.getDriveCardInfo();
    }

    render() {
        return <div>
            <label>用户名: </label><span><h4>{this.props.card.uname}</h4></span>
            <span>驾驶证号: {this.props.card.number}</span>
        </div>
    }
}

// -----------------------************************-----------------------

import {connect} from 'react-redux';
import {getDriveCardInfo} from "./../../redux/action";
import Api from "./../../Api"

const mapStateToProps = (state, ownProps) => ({
    card: state.driveCard
});

const mapDispatchToProps = (dispatch, ownProps) => ({
    getDriveCardInfo: ()=> {
        dispatch(Api.getDriveCardInfo(getDriveCardInfo));
    }
});

const DriveLicense = connect(
    mapStateToProps,
    mapDispatchToProps
)(DriveLicenseApp);

console.log('DriveLicense#Loaded');

export default DriveLicense;

